class Profile < ActiveRecord::Base
	has_one :user
	has_many :educations
	has_many :families
	has_many :researches
	has_many :awards
	has_many :workplaces
	has_many :activities

	acts_as_commentable
	
	has_image :resize_to => "480x640",
		:thumbnails => {
		:face => "180x180",
		:sidebar => "48x48",
		:comment => "36x36"
	},
		:max_size => 3.megabytes,
		:min_size => 4.kilobytes

	validates_presence_of :nameth
	validates_presence_of :lastnameth
	validates_presence_of :nameeng
	validates_presence_of :lastnameeng
	validates_presence_of :nationality
	validates_presence_of :studystatus
	
	def name
		"#{nameth} #{lastnameth} (#{nameeng} #{lastnameeng})"
	end

	def age
		now = Time.now.utc.to_date
		now.year - birthday.year - (birthday.to_date.change(:year => now.year) > now ? 1 : 0)
	end

	def to_label
		"#{nameth} #{lastnameth}, #{nameeng} #{lastnameeng}"
	end

  TITLES = %w[ด.ช. ด.ญ. นาย น.ส. นาง ดร.]
end
